package com.woniuxy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.dao.FeesManagerMapper;
import com.woniuxy.pojo.FeesManager;
import com.woniuxy.service.FeesManagerService;
import com.woniuxy.util.DataGridView;
import com.woniuxy.vo.FeesManagerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class FeesManagerImpl implements FeesManagerService {
    @Autowired
    private FeesManagerMapper feesManagerMapper;

    @Override
    public DataGridView selectFeesManagersByProperty(FeesManagerVo feesManagerVo) {
        Page<Object> page = PageHelper.startPage(feesManagerVo.getPage(), feesManagerVo.getLimit());
        List<FeesManager> feesManagers = this.feesManagerMapper.selectFeesManagersByProperty(feesManagerVo);
        return new DataGridView(page.getTotal(), feesManagers);
    }

    @Transactional
    @Override
    public void deleteFeesManagerById(int id) {
        feesManagerMapper.deleteFeesManagerById(id);
    }
    @Transactional
    @Override
    public void removeFeesManager(Integer[] ids) {
        if (ids != null && ids.length > 0) {
            for (Integer id : ids) {
                this.deleteFeesManagerById(id);
            }
        }
    }

    @Transactional
    @Override
    public boolean insertFeesManager(FeesManager feesManager) {
        boolean flag=false;
        int i = feesManagerMapper.insertFeesManager(feesManager);
        if(i>0){
            flag=true;
        }
        return true;
    }
    @Transactional
    @Override
    public boolean updataFeesManager(FeesManager feesManager) {
        boolean flag=false;
        int i = feesManagerMapper.updataFeesManager(feesManager);
        if (i>0){
            flag=true;
        }
        return flag;
    }

}
